package org.springframework.aop.org.springframework.aop.framework;

import org.springframework.aop.org.springframework.aop.AdvisedSupport;

/**
 * @author xiaohei
 */
public class DefaultAopProxyFactory implements AopProxyFactory {

    private final AdvisedSupport advisedSupport;

    public DefaultAopProxyFactory(AdvisedSupport advisedSupport) {
        this.advisedSupport = advisedSupport;
    }

    @Override
    public AopProxy createAopProxy() {
        if (advisedSupport.isProxyTargetClass()) {
            return new CglibSubclassingAopProxy(advisedSupport);
        } else {
            return new JdkDynamicAopProxy(advisedSupport);
        }
    }
}
